#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int ret = 0;
        for (int i = 0; i < 32; i++)
        {
            int count = 0;
            for (auto x : nums)
            {
                count += (x >> i) & 1;
            }
            ret |= (count % 3) << i;
        }
        return ret;
    }
};